Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide platform name to self-updater #541

Closed
wants to merge 3 commits into from
Closed

Conversation

praj-foss
Copy link
Member

This allows the self-updater to receive the name of the current platform, so it can download the correct assets from GitHub. It reuses the OperatingSystem detected during LauncherInitTask to know the platform name. Fixes #528.

- Check current platform
- Check if latest release has assets for the platform
@praj-foss praj-foss added this to the v4.1.0 milestone Apr 2, 2020
@praj-foss praj-foss added the Type: Maintenance Maintenance or chores not adding new features or fixing bugs. label Apr 2, 2020
- Remove checks for 32-bit system
- Add method to get asset download URL
@praj-foss praj-foss marked this pull request as ready for review April 2, 2020 09:53
} else if (os == OperatingSystem.LINUX) {
platform = "linux";
} else {
logger.warn("Current platform is unsupported: {}", System.getProperty("os.name"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System.getProperty("os.name") - why not print out the os instead? Mabye update the toString to contain more information, if needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be a quick fix. 👍 Since we're planning to get rid of that enum or maybe refactor it at least, it should contain just four constants: windows, mac, linux, and unsupported. So we might need to get it refactored while solving #542 too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need the unsupported constant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd be the default if someone somehow tries to run the launcher on anything other than the three supported platforms. We can use null of course, but I'd suggest avoiding that.

Copy link
Member

@jdrueckert jdrueckert Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what "unsupported" means ;)
I just don't get why we'd need a specific value for that...
Consider you want somebody to slice apples, peel potatoes and throw everything else you find in your kitchen cabinet away, which of the following would you rather write down and why?

A)

- open kitchen cabinet and do for each
    - if "apple": slice
    - if "potato": peel
    - if "everything else": throw away

B)

- open kitchen cabinet and do for each
    - if "apple": slice
    - if "potato": peel
    - else: throw away

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(B) seems natural 👍 (and that's what the else keyword was invented for)

@@ -46,4 +51,14 @@ public String getTagName() {
public String getBody() {
return json.getString("body");
}

public String getDownloadUrl(String platform) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of putting utility methods with logic in here, just expose getAssets which returns a List<GithubAsset> (introduce new class). That class will provide means to getName() and getBrowserDownloadUrl().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy to implement 👍. That's surely the most object-oriented approach, but let me ask if it's really necessary? Like if we are supposed to work with a single target asset (depending on the user's platform), why should we provide a list of assets or their names? 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep all the classes in the github package as generic as possible, so that we could exchange them easily.

The current way we use the github api library is not ideal, as we are dealing with the plain JSON objects. In principle, those libraries offer interfaces similar to what is implemented in that package, so I'm preparing an easy switch.

@skaldarnar skaldarnar added the Status: WIP Work in Progress (not ready for review) label Apr 2, 2020
@skaldarnar skaldarnar modified the milestones: v4.1.0, v4.2.0 May 1, 2020
@skaldarnar skaldarnar closed this Nov 10, 2020
@skaldarnar skaldarnar deleted the topic/self-updates branch November 10, 2020 09:57
@skaldarnar skaldarnar removed this from the v4.2.0 milestone Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: WIP Work in Progress (not ready for review) Type: Maintenance Maintenance or chores not adding new features or fixing bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate platform info into launcher
3 participants